package cn.ava.ymcc.web.controller;

import cn.ava.ymcc.result.JSONResult;
import cn.ava.ymcc.dto.SmsRegisterDto;
import cn.ava.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;


    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult graph(@PathVariable("imageCodeKey") String imageCodeKey) {
        return JSONResult.success(verifyCodeService.getGraph(imageCodeKey));
    }

    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid SmsRegisterDto smsRegisterDto) {
        verifyCodeService.smsCode(smsRegisterDto);
        return JSONResult.success();
    }

}
